import request from '@/utils/request'

const api_name = '/edu/chapter'

export default {
  // 根据课程id获取章节列表
  getNestedTreeList(courseId) {
    return request({
      url: `${api_name}/nested-list/${courseId}`,
      method: 'get'
    })
  },

  // 根据章节id删除章节
  removeById(id) {
    return request({
      url: `${api_name}/${id}`,
      method: 'delete'
    })
  },

  // 新增章节
  save(chapter) {
    return request({
      url: api_name,
      method: `post`,
      data: chapter
    })
  },

  // 根据章节id查询章节
  getById(id) {
    return request({
      url: `${api_name}/${id}`,
      method: 'get'
    })
  },

  // 根据章节id修改章节
  updateById(chapter) {
    return request({
      url: `${api_name}/${chapter.id}`,
      method: 'put',
      data: chapter
    })
  }

}
